/*
* Copyright (c) 2016 ShopJsp. All Rights Reserved.
 * ============================================================================
 * 版权所有 2011 - 今 北京华宇盈通科技有限公司，并保留所有权利。
 * ----------------------------------------------------------------------------
 * 提示：在未取得SHOPJSP商业授权之前，您不能将本软件应用于商业用途，否则SHOPJSP将保留追究的权力。
 * ----------------------------------------------------------------------------
 * 官方网站：http://www.shopjsp.com
 * ============================================================================
*/
package com.hyyt.shopjsp.basic.service.imp;

import java.util.Collection;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.hyyt.shopjsp.basic.vo.BasicStatusRelateVo;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.hyyt.shopjsp.basic.dao.BasicKeyBookDAO;
import com.hyyt.shopjsp.basic.pojo.BasicKeyBook;
import com.hyyt.shopjsp.basic.service.IBasicKeyBookService;
import com.hyyt.shopjsp.util.common.Utils;
/**
* basic_keybook, BASIC_数据字典表
 *
 * @author Robot 14-5-7 上午10:19
 */
@Service
public class BasicKeyBookService implements IBasicKeyBookService {
    private static final Logger logger = Logger.getLogger(IBasicKeyBookService.class);

    @Resource
    private BasicKeyBookDAO basicKeybookDAO;

    /**
     * 初始化数据字典数据，根据类型分组，按value值正向排序
     *
     * @return List<BasicKeybook>
     */
    @Override
    public List<BasicKeyBook> getAllType() {
        return basicKeybookDAO.getAllType();
    }


    /**
     * 通过type查询出对应的数据字典,按value值正向排序
     *
     * @param type 数据字典分类
     * @return
     */
    @Override
    public List<BasicKeyBook> queryKeyBookByType(String type) {
        if (!Utils.stringIsNotEmpty(type)) throw new SecurityException("参数传递有误!");
        return basicKeybookDAO.queryKeyBookByType(type);
    }

    /**
     * 查询针对业务状态的数据字典类型
     */
    @Override
    public List<String> getStatusRelateType() {
        return basicKeybookDAO.getStatusRelateType();
    }

    /**
     * 根据状态类型查询针对业务状态的数据字典数据
     *
     * @param type 业务状态分类
     */
    @Override
    public List<BasicStatusRelateVo> getStatusRelateByType(String type) {
        if (!Utils.stringIsNotEmpty(type)) throw new SecurityException("参数传递有误!");
        return basicKeybookDAO.getStatusRelateByType(type);
    }

    /**
     * 统计BASIC_数据字典表
     *
     * @param params 查询参数，没有则传null,分页参数key为“sortColumns”
     * @return 结果集记录数
     */
    @Override
    public int countBasicKeyBook(Map<String, Object> params) {
        return basicKeybookDAO.count(params);
    }

    /**
     * 查询BASIC_数据字典表
     *
     * @param params   查询参数，没有则传null,分页参数key为“sortColumns”
     * @param startRow 起始行数（不含起始行的数据）
     * @param rowSize  要查询记录数
     * @return BASIC_数据字典集合
     */
    @Override
    public List<BasicKeyBook> queryBasicKeyBook(Map<String, Object> params, int startRow, int rowSize) {
        return basicKeybookDAO.query(params, startRow, rowSize);
    }

    /**
     * 根据ID加载一个BASIC_数据字典表
     *
     * @param id BASIC_数据字典表ID
     * @return BASIC_数据字典表
     */
    @Override
    public BasicKeyBook loadBasicKeyBook(Integer id) {
        return basicKeybookDAO.load(id);
    }

    /**
     * 保存BASIC_数据字典表
     *
     * @param basicKeyBook BASIC_数据字典表
     * @return 保存后的BASIC_数据字典表
     */
    @Override
    public void saveBasicKeyBook(BasicKeyBook basicKeyBook) {
    	basicKeybookDAO.insert(basicKeyBook);
    }

    /**
     * 更新BASIC_数据字典表
     *
     * @param basicKeyBook BASIC_数据字典表
     * @return 更新后的BASIC_数据字典表
     */
    @Override
    public void updateBasicKeyBook(BasicKeyBook basicKeyBook) {
    	basicKeybookDAO.update(basicKeyBook);
    }

    /**
     * 删除指定ID的BASIC_数据字典表
     *
     * @param id BASIC_数据字典表ID
     */
    @Override
    public void deleteBasicKeyBook(Integer id) {
    	basicKeybookDAO.delete(id);
    }

    /**
     * 删除指定ID集合的BASIC_数据字典表
     *
     * @param ids BASIC_数据字典表ID集合
     */
    public void deleteBasicKeyBook(Collection<Integer> ids) {
    	basicKeybookDAO.batchDelete(ids);
    }
}
